home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
telecomm
/
sticpsrc.lzh
/
SOURCE.ARC
/
MAIN.C
< prev
next >
Wrap
Text File
|
1990-10-06
|
43KB
|
1,849 lines
/* Main network program - provides both client and server functions */
#define HOSTNAMELEN 32 /* changed from 16 by Bdale 860812 */
extern char STARTUP[]; /* File to read startup commands from */
extern char ONEXIT[]; /* File to read termination commands from */
#include <stdio.h>
#ifdef ATARI_ST
# ifdef MWC
# include <osbind.h>
# include <basepage.h>
# endif
# ifdef __TURBOC__
# include <tos.h>
extern char *_BasPag; /* base page pointer */
# define BP *_BasPag
# endif
#endif
#include "global.h"
#include "config.h"
#include "mbuf.h"
#include "buffers.h"
#include "netuser.h"
#include "timer.h"
#include "icmp.h"
#include "iface.h"
#include "ip.h"
#include "tcp.h"
#include "ax25.h"
#include "lapb.h"
#include "ftp.h"
#include "telnet.h"
#include "remote.h"
#ifdef SCREEN
#include "screen.h"
#endif
#include "session.h"
#include "cmdparse.h"
#include "kiss.h"
#include "slip.h"
#include "tnc2.h"
#ifdef ASY
#include "asy.h"
#endif
#ifdef NRS
#include "nrs.h"
#endif
#ifdef UNIX /* BSD or SYS5 */
#include <termio.h>
#include "unix.h"
#endif
#ifdef AMIGA
#include "amiga.h"
#endif
#ifdef MAC
#include "mac.h"
#endif
#ifdef CPM
#include "cpm.h"
#endif
#ifdef TRACE
#include "trace.h"
/* Dummy structure for loopback tracing */
struct interface loopback = { NULLIF, "loopback" };
#endif
extern char version[];
extern int vercheck;
extern struct mbuf *loopq;
extern struct mbuf *axloopq;
extern FILE *trfp;
extern char trname[];
int flowctrl = 0;
int mode;
FILE *logfp;
char logname[40];
long starttime;
char badhost[] = "Unknown host \"%s\"\n";
char cantopen[] = "%s: cannot open\n";
char hostname[HOSTNAMELEN];
unsigned nsessions = NSESSIONS;
int32 resolve();
int16 lport = 1001;
char prompt[] = "net> ";
char nospace[] = "No space!!\n"; /* Generic malloc fail message */
static void log_finish();
#if (!defined(MSDOS) && !defined(ATARI_ST)) /* PC/Atari uses F-10 key */
static int escape = 0x1d; /* default escape character is ^] */
#else
static int escape = -2; /* this corrensponds to F10 key */
#endif
/* Command lookup and branch table */
int go(),doax25(),cmdmode(),doconnect(),dotelnet(),doexit(),doclose(),
dohostname(),doreset(),dotcp(),dotrace(),doescape(),dohelp(),dohost(),
doroute(),doecho(),doflow(),dolog(),doip(),doetherstat(),
memstat(),doarp(),dosession(),doftp(),dostart(),dostop(),doattach(),
dosmtp(),doudp(),doparam(),doeol(),dohapnstat(),dobuffers(),
doegstat(),dodump(),dorecord(),doupload(),dokick(),domode(),doshell(),
dodate(),dodelete(),dodir(),docd(),docopy(),dorename(),dormdir(),domkdir(),
dotype(),doatstat(),doping(),dosource(),domheard(),dofinger(),
domorom(),donrstat(),dosccstat(),doauxcon(),doforward(),doremote(),
doscreen(),dosetenv(),dowatchdog(),doat(),dolatency();
struct cmds cmds[] = {
/* The "go" command must be first */
"", go, 0, NULLCHAR, NULLCHAR,
#ifndef CPM
"!", doshell, 0, NULLCHAR, "cannot run shell",
#endif
#if (defined(MAC) && defined(APPLETALK))
"applestat", doatstat, 0, NULLCHAR, NULLCHAR,
#endif
#if (defined(IP) && (defined(AX25) || defined(ETHER) || defined(APPLETALK)))
"arp", doarp, 0, NULLCHAR, NULLCHAR,
#endif
#if (!defined(MSDOS) || defined(MSC) || defined(__TURBOC__))
"at", doat, 0, NULLCHAR, NULLCHAR,
#endif
"attach", doattach, 2,
"<hardware> <hw specific options>", NULLCHAR,
#if (defined(ATARI_ST) && defined(MWC))
"auxcon", doauxcon, 2, "<io code> [speed [7|8 [noflow]]]", NULLCHAR,
#endif
#ifdef AX25
"ax25", doax25, 0, NULLCHAR, NULLCHAR,
#endif
#ifdef SCC
"buffers", dobuffers, 0, NULLCHAR, NULLCHAR,
#endif
/* This one is out of alpabetical order to allow abbreviation to "c" */
#ifdef AX25
"connect", doconnect, 3, "<interface> <callsign> [digipeaters]",
NULLCHAR,
#endif
#if (!defined(CPM) && !defined(UNIX)) /* BSD or SYS5 */
"cd", docd, 0, NULLCHAR, NULLCHAR,
#endif
"close", doclose, 0, NULLCHAR, NULLCHAR,
#if (!defined(CPM) && !defined(UNIX)) /* BSD or SYS5 */
"copy", docopy, 3, "<file> ... <dest>", NULLCHAR,
"date", dodate, 0, NULLCHAR, "Usage: date [mmddhhmmss[yy]]",
"delete", dodelete, 2, "[-f] <file> ...", NULLCHAR,
"dir", dodir, 0, NULLCHAR, NULLCHAR,
#endif
"disconnect", doclose, 0, NULLCHAR, NULLCHAR,
#ifdef EAGLE
"eaglestat", doegstat, 0, NULLCHAR, NULLCHAR,
#endif
#ifdef IP
"echo", doecho, 0, NULLCHAR, "echo options: refuse accept",
"eol", doeol, 0, NULLCHAR, "eol options: unix standard",
#endif
"escape", doescape, 0, NULLCHAR, NULLCHAR,
#ifdef PC_EC
"etherstat", doetherstat, 0, NULLCHAR, NULLCHAR,
#endif
"exit", doexit, 0, NULLCHAR, NULLCHAR,
#ifdef IP
"finger", dofinger, 2, "[<user>][@<host>]",
"Usage: finger <user> | <user>@<host> | @<host>",
#endif
"flow", doflow, 0, NULLCHAR, NULLCHAR,
"forward", doforward, 0, NULLCHAR, NULLCHAR,
#if (defined(IP) && defined(FTPC))
"ftp", doftp, 2, "<address> [<port> [<tos>]]", NULLCHAR,
#endif
#ifdef HAPN
"hapnstat", dohapnstat, 0, NULLCHAR, NULLCHAR,
#endif
"help", dohelp, 0, NULLCHAR, NULLCHAR,
#ifdef IP
"host", dohost, 2, "<hostname>|[ip_address]", NULLCHAR,
"hostname", dohostname, 0, NULLCHAR, NULLCHAR,
"ip", doip, 0, NULLCHAR, NULLCHAR,
#endif
"kick", dokick, 0, NULLCHAR, NULLCHAR,
#ifdef ATARI_ST
"latency", dolatency, 2, "yes|no|raw|stat", "Usage: latency yes|no|raw|stat",
#endif
#ifdef SERVERS
"log", dolog, 0, NULLCHAR, NULLCHAR,
#endif
#if (defined(MSDOS) || defined(ATARI_ST) || defined(UNIX))
"memstat", memstat, 0, NULLCHAR, NULLCHAR,
#endif
#ifdef MHEARD
"mheard", domheard, 2, "<interface> [<maxheard>|clear]", NULLCHAR,
#endif
#if (!defined(CPM) && !defined(UNIX)) /* BSD or SYS5 */
"mkdir", domkdir, 2, "[-f] <dir> ...", NULLCHAR,
#endif
#if (defined(IP) && defined(AX25))
"mode", domode, 2, "<interface>", NULLCHAR,
#endif
#ifdef NETROM
"morom", domorom, 0, NULLCHAR, NULLCHAR,
#endif
#ifdef NRS
"nrstat", donrstat, 0, NULLCHAR, NULLCHAR,
#endif
"param", doparam, 2, "<interface>", NULLCHAR,
#ifdef IP
"ping", doping, 0, NULLCHAR, NULLCHAR,
#endif
#if (!defined(CPM) && !defined(UNIX)) /* BSD or SYS5 */
"pwd", docd, 0, NULLCHAR, NULLCHAR,
#endif
"record", dorecord, 0, NULLCHAR, NULLCHAR,
#ifdef IP
"remote", doremote, 4, "<address> <port> <command>",
NULLCHAR,
#endif
#if (!defined(CPM) && !defined(UNIX)) /* BSD or SYS5 */
"rename", dorename, 3, "<oldname> <newname>", NULLCHAR,
#endif
"reset", doreset, 0, NULLCHAR, NULLCHAR,
#if (!defined(CPM) && !defined(UNIX)) /* BSD or SYS5 */
"rmdir", dormdir, 2, "[-f] <dir> ...", NULLCHAR,
#endif
#ifdef IP
"route", doroute, 0, NULLCHAR, NULLCHAR,
#endif
/* This one is out of alpabetical order to allow abbreviation to "s" */
"session", dosession, 0, NULLCHAR, NULLCHAR,
#ifdef SCC
"sccstat", dosccstat, 0, NULLCHAR, NULLCHAR,
#endif
#if (defined(ATARI_ST) && defined(MWC))
"screen", doscreen, 2, "bios|direct|tos", "screen options: bios direct tos",
#endif
"setenv", dosetenv, 0, NULLCHAR, "setenv failed",
#ifndef CPM
"shell", doshell, 0, NULLCHAR, "cannot run shell",
#endif
#if (defined(IP) && defined(SMTPC))
"smtp", dosmtp, 0, NULLCHAR, NULLCHAR,
#endif
"source", dosource, 2, "<file>", NULLCHAR,
#ifdef SERVERS
"start", dostart, 2, "<servername>",NULLCHAR,
"stop", dostop, 2, "<servername>", NULLCHAR,
#endif
#ifdef IP
"tcp", dotcp, 0, NULLCHAR, NULLCHAR,
"telnet", dotelnet, 2, "<address> [<port> [<tos>]]", NULLCHAR,
#endif
#ifdef TRACE
"trace", dotrace, 0, NULLCHAR, NULLCHAR,
#endif
#if (!defined(CPM) && !defined(UNIX)) /* BSD or SYS5 */
"type", dotype, 2, "<file> [<lines>]", NULLCHAR,
#endif
#ifdef IP
"udp", doudp, 0, NULLCHAR, NULLCHAR,
#endif
"upload", doupload, 0, NULLCHAR, NULLCHAR,
#if (defined(MSDOS) || defined(ATARI_ST))
"watchdog", dowatchdog, 0, NULLCHAR, NULLCHAR,
#endif
"?", dohelp, 0, NULLCHAR, NULLCHAR,
NULLCHAR, NULLFP, 0,
"Unknown command; type \"?\" for list", NULLCHAR
};
#ifdef SERVERS
/* "start" and "stop" subcommands */
int dis1(),echo1(),fin